package com.tcl.hystrix;

import com.google.common.collect.Lists;
import com.tcl.api.request.UserAddRequest;
import com.tcl.api.response.ResultMsg;
import com.tcl.api.response.UserResponse;
import com.tcl.feign.UserServiceFeignClient02;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author liuf
 * @Date 2021/1/9 10:45
 * @Description
 */
@Slf4j
@Component
public class UserServiceFeignFallBack implements FallbackFactory<UserServiceFeignClient02> {

    @Override
    public UserServiceFeignClient02 create(Throwable cause) {
        log.error("服务降级回调", cause);

        return new UserServiceFeignClient02() {
            @Override
            public UserResponse get(Integer id) {
                return new UserResponse();
            }

            @Override
            public UserResponse get2(Integer id) {
                return new UserResponse();
            }

            @Override
            public ResultMsg get3(Integer id) {
                return new ResultMsg();
            }

            @Override
            public List<UserResponse> list(String name, Integer gender) {
                return Lists.newArrayList();
            }

            @Override
            public List<UserResponse> list2(UserAddRequest request) {
                return Lists.newArrayList();
            }

            @Override
            public UserAddRequest add(UserAddRequest request) {
                return request;
            }

            @Override
            public UserAddRequest add2(UserAddRequest request) {
                return request;
            }

            @Override
            public ResultMsg error(Integer id) {
                return new ResultMsg();
            }
        };
    }
}
